﻿using System.Collections;
using UnityEngine;

#if UNITY_EDITOR
using UnityEditor;
#endif

public class GT_NodePropertyView : GT_ViewBase
{
    public bool showProperties = false;

    public GT_NodePropertyView() : base("Property View") { }

    #region Main Methods
    public override void UpdateView(Rect editorRect, Rect percentageRect, Event e, GT_NodeGraph curGraph)
    {
        base.UpdateView(editorRect, percentageRect, e, curGraph);
        GUI.Box(viewRect, viewTitle, viewSkin.GetStyle("ViewBG"));

        GUILayout.BeginArea(viewRect);

        GUILayout.Space(60);
        if (!curGraph.showProperties)
        {
            EditorGUILayout.LabelField("None");
        } else
        {
            curGraph.selectedNode.DrawNodeProperties();
        }

        GUILayout.EndArea();

        ProcessEvent(e);


    }

    public override void ProcessEvent(Event e)
    {
        base.ProcessEvent(e);


        if (viewRect.Contains(e.mousePosition))
        {
            if (e.button == 0)
            {
                if (e.type == EventType.MouseDown)
                {

                }
                if (e.type == EventType.MouseDrag)
                {

                }
                if (e.type == EventType.MouseUp)
                {

                }
            }

            if (e.button == 1)
            {
                if (e.type == EventType.MouseDown)
                {
                    ProcessContextMenu(e);
                }
            }
        }
    } 
    #endregion

    #region Utility Methods
    private void ProcessContextMenu(Event e)
    {
        //GenericMenu menu = new GenericMenu();
        //menu.AddItem(new GUIContent("CreateGraph"), false, ContextCallback, "0");
        //menu.ShowAsContext();
        //e.Use();
    }
    #endregion
}
